package bairui.international.console.web.controller.wrap.category.product;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.servlet.ModelAndView;

import com.lianjing.sh.project.config.web.Project_Config_Web_PageTemplate;
import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.base.operate.OperateSupport;
import com.lianjing.sh.spring.web.controller.enhance.module.context.ModuleContext;
import com.lianjing.sh.spring.web.controller.enhance.navigations.context.NavigationContext;

import bairui.international.model.domain.jpa.TB_Product;
import bairui.international.service.Service_Product;

/**
 *
 * 产品详情编辑
 *
 * @generated
 * 
 * @see STest_C_Wrap_Category_ProductDetailEdit_EditAccess 测试
 *
 */
@Controller
public class C_Wrap_Category_ProductDetailEdit_EditAccess
 extends SC_Wrap_Category_ProductDetailEdit_EditAccess 
{
	
	@Autowired private Service_Product service_Product;
	
	/**
	 * 访问编辑页面
	 */
	@Action(EditAccess.class)
	@GetMapping(EditAccess.RequestMappingValue)
	public ModelAndView editAccess(
		ModelMap map, HttpServletRequest request,
		NavigationContext navigationContext, ModuleContext moduleContext, 
		@PathVariable(name=EditAccess.PathVariableName.CategoryId) long categoryId, 
		@PathVariable(name=EditAccess.PathVariableName.Id) long id
	) throws Exception {
		TB_Product bean = service_Product.findById(id);
		/* 模块 */
		moduleContext
			.addModule(module_ProductDetailEdit.module(
					bean,
					new C_Wrap_Category_ProductDetailEdit_Edit.Edit.Operate(){
						@Override public Object getCategoryId() { return categoryId; }
						@Override public Object getId() { return id; }
						@Override public OperateSupport returnTo() {
							return new C_Wrap_Category_ProductRollUpload_PageAccess.PageAccess.Operate() {
								@Override public Object getId() {
									return "{{:}}";
								}
								@Override public Object getCategoryId() {
									return categoryId;
								}
//								@Override public com.lianjing.sh.spring.web.controller.base.operate.OperateTarget target() {
//									return OperateTarget.Popup;
//								};
							};
						}	
					}
				));
		//
		return Project_Config_Web_PageTemplate.Admin_Common(request);
	}
	

}
